﻿
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using Model;
using MsDAL;
using System.ComponentModel;
using Components;

namespace ServiceHelper
{
    [DataObjectAttribute]
    public partial class Psn0a00Manager : Psn0a00Base
    {
        private static Psn0a00Manager _entity;

        public static Psn0a00Manager Entity
        {
            get
            {
                if (_entity == null)
                    _entity = new Psn0a00Manager();
                return _entity;
            }
        }

        #region 个人代码
        public string SaveData(Hashtable tb, string action, string usercode)
        {
            List<SqlApp> lst = new List<SqlApp>();

            Psn0a00 model = new Psn0a00();
            CommonUtil.GetInstance.CopyProperties(tb, model);
            model.Usercode = Context.GetAppByUserCode(usercode);

            if ("A" == action)
            {
                lst.Add(this.Add(model));
            }
            else if ("M" == action)
            {
                lst.Add(this.Update(model));
            }
            else if ("T" == action) //公司设置
            {
                string[] fiter = { "comcode", "comname" };

                string comcode = Validation.ToString(tb["comcode"]);
                Psn0a01 pm = null;
                string key = string.Empty;
                foreach (DictionaryEntry entry in tb)
                {
                    key = Validation.ToString(entry.Key);
                    if (Array.IndexOf(fiter, key) >= 0) continue;

                    pm = new Psn0a01();
                    pm.Comcode = comcode;
                    pm.Item = key.Replace("p", ""); //控件以P开头
                    pm.Value1 = Validation.ToString(entry.Value);

                    lst.Add(psn0a00Dal.AddOrUpdateSetting(pm));
                }
            }

            return CommonManager.Entity.SaveData(lst);
        }

        #endregion
    }
}



